package com.example.myandroid01;

import android.view.MenuItem;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class BottonNavDemoActivity extends AppCompatActivity {
    private BottomNavigationView btmNavView;
    private TextView btmNavTextView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_botton_nav_demo);
        btmNavView=findViewById(R.id.bottom_navigation_menu);
        btmNavTextView=findViewById(R.id.text_msg);
        btmNavView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
                switch (menuItem.getItemId()){
                    case R.id.navigation_home:
                        btmNavTextView.setText(R.string.title_home);
                        return true;
                    case R.id.navigation_friends:
                        btmNavTextView.setText(R.string.title_friends);
                        return true;
                    case R.id.navigation_msg:
                        btmNavTextView.setText(R.string.title_msg);
                        return true;
                }
                return false;
            }
        });
    }
}
